﻿USE lsk
GO
CREATE TABLE #AW_Picture(
	[PictureId] [uniqueidentifier] NOT NULL,
	[Picture] [nvarchar](max) NOT NULL,
	[PropertyId] [uniqueidentifier] NOT NULL,
	[pictureURL] [nvarchar](200) NULL,
	[PhotoId] [varchar](50) NULL,
	[MediumUrl] [varchar](500) NULL,
	[SmallUrl] [varchar](500) NULL,
	[LargeUrl] [varchar](500) NULL,
)


BULK
INSERT #AW_Picture
FROM 'D:\Cloud\SkyDrive\LSK\MigrationTool\Script\AW_Picture.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO


BEGIN Tran
UPDATE AW SET AW.PhotoId = temp.PhotoId,
			  AW.pictureURL = temp.pictureURL,
			  AW.MediumUrl = temp.MediumUrl,
			  AW.SmallUrl = temp.SmallUrl,
			  AW.LargeUrl = temp.LargeUrl
	FROM AW_Picture AW
JOIN #AW_Picture temp on temp.PictureId = AW.PictureId

commit tran


DROP TABLE #AW_Picture

PRINT '==========================DONE Update=========================='